# Contributor: Michael Mason <ms13sp@gmail.com>
# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=screen
pkgver=5.0.0
pkgrel=0
pkgdesc="Window manager that multiplexes a physical terminal"
url="https://www.gnu.org/software/screen/"
arch="all"
license="GPL-3.0-or-later"
makedepends="
	autoconf
	automake
	linux-pam-dev
	ncurses
	ncurses-dev
	"
subpackages="$pkgname-doc"
source="https://ftp.gnu.org/gnu/screen/screen-$pkgver.tar.gz"
options="!check"  # No test suite.

# secfixes:
#   4.9.0-r3:
#     - CVE-2023-24626
#   4.8.0-r4:
#     - CVE-2021-26937
#   4.8.0-r0:
#     - CVE-2020-9366

prepare() {
	default_prepare
	./autogen.sh
}

build() {
	CFLAGS="$CFLAGS -flto=auto" \
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--with-sys-screenrc=/etc/screenrc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--enable-colors256 \
		--enable-telnet \
		--enable-rxvt_osc
	make
}

package() {
	make -j1 DESTDIR="$pkgdir" install

	# remove suid root
	find "$pkgdir" -type f -perm -u+s -print0 \
		| xargs -0 chmod -c -s

	install -Dm644 etc/etcscreenrc "$pkgdir"/etc/screenrc
	install -Dm644 etc/screenrc "$pkgdir"/etc/skel/.screenrc
}

sha512sums="
18a163313025c58950ec65fa83037ba1df0fa8e2346925593217fb0a6596f2f51914a4f0aec7f0e1c280d3d3ef964e7a886521f41f4b96f4ff08935be7f62117  screen-5.0.0.tar.gz
"
